<?php


namespace App\Modules\System\Services;


use App\Lib\Facades\FLAuth;
use App\Modules\System\Repositories\MyVisitHistoryRepository;
use App\Modules\System\Repositories\VisitorHistoryRepository;
use Flower\Core\Repository\Eloquent\BaseService;

class VisitorHistoryService  extends BaseService
{
    public static function createOrUpdateVisitor($storeId,$source,$linkName){
        $memberId = $source == config('constant.visitor_source.out_side') ? 0 : FLAuth::id();
        $isBarber = [config('constant.visitor_source.portfolio'),config('constant.visitor_source.barber_master')];
        // 类型1门店 2理发师
        $category = $source ==  config('constant.visitor_source.out_side') ? 0 : (in_array($source,$isBarber) ? 2 : 1);
        $linkName = empty($linkName) ?  "" : $linkName;
        return (new VisitorHistoryRepository())->add($storeId,$memberId,$source,$category,$linkName);
    }


    public static function createOrUpdateVisitorByBarber($barberId,$storeId,$source,$linkName){
	    $memberId = $source == config('constant.visitor_source.out_side') ? 0 : FLAuth::id();
	    $linkName = empty($linkName) ?  "" : $linkName;
	    return (new MyVisitHistoryRepository())->add($barberId,$storeId,$memberId,$source,$linkName);
    }
}
